<?php if (!defined('THINK_PATH')) exit();?><!doctype html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8"/>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"/>
    <title>订单详情</title>
    <link rel="stylesheet" type="text/css" href="/Public/vendor/font-awesome/css/font-awesome.css"/>
    <link rel="stylesheet" type="text/css" href="/Public/assets/home/css/common.css"/>
</head>
<body>

<ul class="menu">
    <li class="on"><a class="current" href="<?php echo U('orders',array('status'=>'all'));?>">全部</a></li>
    <li><a href="<?php echo U('orders',array('status'=>'1'));?>">待发货</a></li>
    <li><a href="<?php echo U('orders',array('status'=>'2'));?>">已发货</a></li>
    <li><a href="<?php echo U('orders',array('status'=>'3'));?>">已完成</a></li>
</ul>

<?php if(is_array($all_orders)): $i = 0; $__LIST__ = $all_orders;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$order): $mod = ($i % 2 );++$i;?><div class="order">
        <h2>订单号：<?php echo ($order["order_no"]); ?></h2>
        <?php if($order['order_status'] == 1){ ?>
        <h4 class="deliver"><img src="/Public/assets/home/images/bg05.png" alt="待发货"></h4>
        <?php }elseif($order['order_status'] == 2){ ?>
        <h4 class="send"><img src="/Public/assets/home/images/bg03.png" alt="已发货"></h4>
        <?php }else{ ?>
        <h4 class="finish"><img src="/Public/assets/home/images/bg02.png" alt="已完成"></h4>
        <?php } ?>
        <dl>
            <dt><img class="img-responsive" src="<?php echo ($order["thumb"]); ?>" alt="产品图片"></dt>
            <dd><?php echo ($order["name"]); ?></dd>
            <dd><span>x <?php echo ($order["number"]); ?></span>¥ <?php echo ($order["price"]); ?>元</dd>
        </dl>

        <p>总价：<em>¥ <?php echo ($order["total_price"]); ?>元</em>
            <?php if(in_array(($order["order_status"]), explode(',',"2"))): ?><i class="cancel" data-id="<?php echo ($order["id"]); ?>" data-status="<?php echo ($order["order_status"]); ?>">取消订单</i><?php endif; ?>
        </p>
    </div><?php endforeach; endif; else: echo "" ;endif; ?>


<script type="text/javascript" src="/Public/assets/home/js/jquery.min.js"></script>
<script type="text/javascript" src="/Public/vendor/sticky/jquery.sticky.js"></script>
<script type="text/javascript" src="/Public/assets/home/js/order.js"></script>
<script type="text/javascript">
    $(function () {

        //取消订单
        $('.cancel').click(function () {
            if (confirm('确定要取消此订单么？')) {
                var id = $(this).attr('data-id');
                var status = $(this).attr('data-status');
                $.post("<?php echo U('cancel_order');?>", {
                    id: id,
                    status: status
                }, function () {
                    window.location.reload();
                })
            }
        });
    })
</script>
</body>
</html>